const CompressionPlugin = require("compression-webpack-plugin")

module.exports={
  publicPath:'/admin/',
  outputDir:'dist',
  devServer: {
    open: process.platform === "darwin",
    host: "0.0.0.0", // 允许外部ip访问
    port: 8080, // 端口
    https: false, // 启用https
    overlay: {
      warnings: false,
      errors: false
    }, // 错误、警告在页面弹出
    proxy: {
      "/mock": {
        target: "http://127.0.0.1:8081/",
        changeOrigin: true, // 允许websocket跨域
        // ws: true,
        pathRewrite: {
          "^/mock": ""
        }
      }
    } // 代理转发配置，用于调试环境
  },
  //开启gzip
  configureWebpack: () => {
    if (process.env.NODE_ENV === 'prod') {
        return {
          plugins:[new CompressionPlugin({
            test: /\.js$|\.html$|\.css/,
            threshold: 10240,
            deleteOriginalAssets:false
          })]
        }  
      }
  },
}